110be3
@@ -46,6 +46,7 @@
import org.springframework.web.util.WebUtils;
  *
  * @author Arjen Poutsma
  * @author Rossen Stoyanchev
+ * @author Juergen Hoeller
  * @since 3.0
  */
 public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
@@ -246,6 +247,17 @@
public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
 			}
 		}
 
+		// Overrides Servlet 3.1 setContentLengthLong(long) at runtime
+		public void setContentLengthLong(long len) {
+			if (len > Integer.MAX_VALUE) {
+				throw new IllegalArgumentException("Content-Length exceeds ShallowEtagHeaderFilter's maximum (" +
+						Integer.MAX_VALUE + "): " + len);
+			}
+			if (len > this.content.capacity()) {
+				this.content.resize((int) len);
+			}
+		}
+
 		@Override
 		public void setBufferSize(int size) {
 			if (size > this.content.capacity()) {
